﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class per_phone_validation : MpageBase
{
    protected Model.CMember CMember = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (loginUserInfo != null && loginUserInfo.Id > 0)
        {
            CMember = BLL.CMember.GetModel(loginUserInfo.Id);
        }

        if (!IsPostBack)
        {
            realnameTXT.Text = CMember.realname;
            cardidTXT.Text = CMember.cardid;
        }
    }
    protected void btn_Click(object sender, EventArgs e)
    {
        string trendsCode = System.Web.HttpContext.Current.Session[NtHelp.regitCode].ToString();
        if (checkcode.Text.Trim().ToUpper().Equals(trendsCode))
        {
            if (cardidTXT.Text.Trim().Length > 18 || cardidTXT.Text.Trim().Length < 15 || realnameTXT.Text.Trim().Length < 1)
            {
                if (realnameTXT.Text.Trim().Length < 1)
                {
                    alertmessageAndGoback("用户名的长度不得小于1！");
                }
                if (cardidTXT.Text.Trim().Length > 18 || cardidTXT.Text.Trim().Length < 15)
                {
                    alertmessageAndGoback("身份证的长度必须在15-18之间！");
                }
            }
            else
            {
                CMember.realname = realnameTXT.Text.Trim();
                CMember.cardid = cardidTXT.Text.Trim();
                System.Web.HttpContext.Current.Session[BLL.CMember.LoginUserSessionKey] = CMember;
                if (BLL.CMember.Update(CMember) > 0)
                {
                    System.Web.HttpContext.Current.Response.Write("<script type=\"text/javascript\">alert('验证成功！');top.window.location.href = '/personal.aspx?m=0';</script>");

                }
            }
        }
        else
        {
            alertmessageAndGoback("验证码错误！");
        }
    }
}